package com.onlinevideo.dao.impl;

import com.onlinevideo.dao.BaseDao;
import com.onlinevideo.dao.RoleDao;
import com.onlinevideo.entity.Role;
import com.onlinevideo.entity.User;

import java.util.List;

public class RoleDaoImpl extends BaseDao implements RoleDao {
    @Override
    public int insert(Role role) {
        String sql ="INSERT INTO `T_role` (`role_name`,`role_description`,`role_status`) VALUES (?,?,?)";
        return super.update(sql,role.getRoleName(),role.getRoleDescription(),role.getRoleStatus());
    }

    @Override
    public int delete(Long id) {
        String sql = "DELETE FROM `T_role` WHERE `id`=?";
        return super.update(sql,id);
    }

    @Override
    public int update(Role role) {
        String sql ="UPDATE `T_role` SET `role_name`=?,`role_description`=?,`role_status`=? WHERE `id`=?";
        return super.update(sql,role.getRoleName(),role.getRoleDescription(),role.getRoleStatus(),role.getId());
    }

    @Override
    public Role queryById(Long id) {
        String sql = "SELECT `id`,`role_name` AS `roleName`,`role_description` AS `roleDescription`,`role_status` AS `roleStatus` FROM `T_role` WHERE 1=1 AND `id`=?  ";
        return super.queryForOne(Role.class,sql,id);
    }

    @Override
    public List<Role> queryAll() {
        String sql = "SELECT `id`,`role_name` AS `roleName`,`role_description` AS `roleDescription`,`role_status` AS `roleStatus` FROM `T_role` WHERE 1=1 ";
        return super.queryForList(Role.class,sql);
    }

    @Override
    public  List<Role> queryForPageItems(int begin, int pageSize) {
        return null;
    }

    @Override
    public Integer queryForPageTotalCount() {
        return null;
    }

    @Override
    public  List<Role> queryForPageItems(int begin, int pageSize, Role t) {
        return null;
    }

    @Override
    public Integer queryForPageTotalCount(Role t) {
        return null;
    }


}
